<<<<<<< HEAD
/*
 * @Author: Ryan Huang
 * @Description:
 * @Date: 2019-04-06 12:13:51
 */
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type CharCount struct {
	EnCount    int
	NumCount   int
=======
package main

import (
	"os"
	"bufio"
	"io"
	"fmt"
	"unsafe"
)

type CharCount struct {
	EnCount int
	NumCount int
>>>>>>> 5ff4299df15cebcc96b503c1bef32f6520030e85
	SpaceCount int
	OtherCount int
	EnterCount int
}

<<<<<<< HEAD
func main() {
	filePath := "./1.txt"
	file, _ := os.Open(filePath)
=======
func main(){
	filePath := "./1.txt"
	file,_ := os.Open(filePath)
>>>>>>> 5ff4299df15cebcc96b503c1bef32f6520030e85
	defer file.Close()
	var count CharCount
	reader := bufio.NewReader(file)
	for {
		str, err := reader.ReadString('\n')
		line := []rune(str)
<<<<<<< HEAD
		for _, v := range line {
=======
		for _,v := range line {
>>>>>>> 5ff4299df15cebcc96b503c1bef32f6520030e85
			//fmt.Println(v)
			switch {
			case v >= 'a' && v <= 'z':
				fallthrough
			case v >= 'A' && v <= 'Z':
				count.EnCount++
			case v == ' ' || v == '\t':
				count.SpaceCount++
			case v >= '0' && v <= '9':
				count.NumCount++
			case v == '\n':
				count.EnterCount++
			default:
				count.OtherCount++
			}
		}
<<<<<<< HEAD
		if err == io.EOF {
			break
		}
	}
	fmt.Printf("英语字符%d个，数字%d个，空格%d个，其他%d个", count.EnCount, count.NumCount, count.SpaceCount, count.OtherCount)
}
=======
		if err == io.EOF{
			break
		}
	}
	fmt.Printf("英语字符%d个，数字%d个，空格%d个，其他%d个",count.EnCount,count.NumCount,count.SpaceCount,count.OtherCount)
}
>>>>>>> 5ff4299df15cebcc96b503c1bef32f6520030e85
